export function scrollerX(element, to, duration) {

  if (duration <= 0) {
    return;
  }
  const difference = to - element.scrollLeft;
  const perTick = difference / duration * 10;
  setTimeout(() => {
    element.scrollLeft = element.scrollLeft + perTick;
    if (element.scrollLeft === to) {
      return;
    }
    scrollerX(element, to, duration - 10)
  }, 1)
}
export function scrollTo(element, to, duration) {
  if (duration <= 0) return
  const difference = to - element.scrollTop
  const perTick = difference / duration * 10
  setTimeout(() => {
    element.scrollTop = element.scrollTop + perTick
    console.log(element.scrollTop)
    if (element.scrollTop === to) return
    scrollTo(element, to, duration - 10)
  }, 10)
}
export function assignCopy(target, source) {
  for (var obj in source) {
    if (typeof source[obj] == "object" && typeof target[obj] == "object" && source[obj]) {
      assignCopy(target[obj], source[obj]);
    } else {

      if (source[obj] || source[obj] == 0) {
        target[obj] = source[obj];
      }
    }
  }
  return target;

}
